#include "DisplayManager.h"

/* PROTECTED REGION ID(Controller::DisplayManager_customCode) ENABLED START */

#include "fixedpoint.h"
#include "ustdlib.h"

/* PROTECTED REGION END */

void DisplayManager_Runnable_initialize(void) {
	/* PROTECTED REGION ID(Controller::DisplayManager_RunnableInitializeFunc) ENABLED START */
	/*
	 * TODO: Put runnable initialization code here.
	 */
	/* PROTECTED REGION END */
}

void DisplayManager_Runnable(void) {
	/* PROTECTED REGION ID(Controller::DisplayManager_RunnableFunc) ENABLED START */
	int32_t desiredTemperature = 25;
	int32_t actualTemperature = 0;
	int power = 0;
	char s[32];

	DisplayManager_desiredTemperature_receive(&desiredTemperature);
	DisplayManager_actualTemperature_receive(&actualTemperature);
	DisplayManager_power_receive(&power);

	usprintf(s, "Desired T: %d      ", FIX_TO_INT(desiredTemperature));
	DisplayManager_display_drawString(s, 0, 0);
	{
		int32_t integer;
		int32_t fraction;
		getIntegerFraction(actualTemperature, 10, &integer, &fraction);
		usprintf(s, "Actual T : %d.%d   ", integer, fraction);
		DisplayManager_display_drawString(s, 0, 16);
	}
	usprintf(s, "Power    : %d%%    ", power);
	DisplayManager_display_drawString(s, 0, 32);
	/* PROTECTED REGION END */
}
